package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dindang.propertyfee.app.AppConst;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.propertyfee.di.component.DaggerFeeList2Component;
import com.dindang.propertyfee.di.module.FeeList2Module;
import com.dindang.propertyfee.mvp.contract.FeeList2Contract;
import com.dindang.propertyfee.mvp.presenter.FeeList2Presenter;

import com.dindang.propertyfee.R;
import com.longxi.gamer_base.widget.EmptyLayout;


import in.srain.cube.views.ptr2.PtrClassicFrameLayout;

import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/FeeList2Activity")
public class FeeList2Activity extends BaseActivity<FeeList2Presenter> implements FeeList2Contract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    ImageView mIvSort;
    PtrClassicFrameLayout mPtrclassicframelayout;
    RecyclerView mRecyclerview;
    EmptyLayout mEmptyLayout;
    TextView mTvTotal;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerFeeList2Component //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .feeList2Module(new FeeList2Module(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_fee_list2; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mIvSort = findViewById(R.id.propertyfee_iv_right);
        mPtrclassicframelayout = findViewById(R.id.propertyfee_ptrclassicframelayout);
        mRecyclerview = findViewById(R.id.propertyfee_recyclerview);
        mEmptyLayout = findViewById(R.id.propertyfee_emptyLayout);
        mTvTotal = findViewById(R.id.propertyfee_tv_total);

        mIvSort.setVisibility(View.VISIBLE);
        mIvSort.setImageResource(R.mipmap.propertyfee_ic_sort);
        mIvSort.setOnClickListener(v -> mPresenter.sortDialog());
        mTvTitle.setText(getIntent().getStringExtra(AppConst.DUE_TO));
        mIvBack.setOnClickListener(v -> finish());

        mPresenter.init();
        mPresenter.initParam(getIntent().getStringExtra(AppConst.DUE_TO));
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public ImageView getIvBack() {
        return mIvBack;
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public ImageView getIvSort() {
        return mIvSort;
    }

    @Override
    public PtrClassicFrameLayout getPtrclassicframelayout() {
        return mPtrclassicframelayout;
    }

    @Override
    public RecyclerView getRecyclerview() {
        return mRecyclerview;
    }

    @Override
    public EmptyLayout getEmptyLayout() {
        return mEmptyLayout;
    }

    @Override
    public TextView getTvTotal() {
        return mTvTotal;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
